import os
import subprocess


class Cmd:
    def __init__(self):
        pass

    def run(self):
        command_list = [
            'dir'
        ]
        p = subprocess.Popen(command_list, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                             encoding='gbk')
        lines = p.communicate()[0]
        for line in lines.splitlines():
            print(f'执行结果 {line}')


if __name__ == '__main__':
    ai = Cmd()
    ai.run()
